<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<html>
<head>
	<script type="text/javascript" src="scripts/boot.js"></script>
	<style type="text/css">
    .errorText
    {
        color:red;
    }
    </style>
</head>
<body>
	<form id="form1" method="post">
	<input name="id" class="mini-hidden" />
        <div style="padding-left:50px;padding-bottom:15px;padding-top: 25px;">
            <table style="table-layout:fixed;" cellspacing="0" cellpadding="10">
            	<tr>
                    <td>添加时间：</td>
                    <td>
                   		<input name="reminderTime" errorMode="none" onvalidation="checkValidation"  requiredErrorText="请选择日期" class="mini-datepicker" required="true" style="width: 180px" emptyText="请选择日期"
                   		format="yyyy-MM-dd H:mm:ss" timeFormat="H:mm:ss" showTime="true" showOkButton="true" showClearButton="false"/>
                	</td>
                	<td id="reminderTime_error" class="errorText" ></td>
                </tr>
                <tr>
            		<td>提醒内容：</td>
                    <td>    
                        <input name="content" errorMode="none" onvalidation="onserialNumValidation"  requiredErrorText="请输入" vtype="maxLength:85" class="mini-textbox" required="true" style="width: 180px"/>
                    </td>
                    <td id="content_error" class="errorText" ></td>
                </tr>
                <tr>
            		<td>提醒周期：</td>
                    <td>    
                        <input name="cycle" errorMode="none" onvalidation="onserialNumValidation"  requiredErrorText="请输入" vtype="maxLength:15" class="mini-textbox" required="true" style="width: 180px"/>
                    </td>
                    <td id="cycle_error" class="errorText" ></td>
                </tr>
                <tr>
            		<td>提醒目标客服：</td>
                    <td>    
                        <input name="operator" errorMode="none" onvalidation="onserialNumValidation"  requiredErrorText="请输入" vtype="maxLength:15" class="mini-textbox" required="true" style="width: 180px"/>
                    </td>
                    <td id="operator_error" class="errorText" ></td>
                </tr>
            </table>
        </div>
        <div style="text-align:center;padding-top:20px;">
            <a class="mini-button" onclick="onOk" style="width:60px;margin-right:50px;">确定</a>       
            <a class="mini-button" onclick="onCancel" style="width:60px;">取消</a>       
        </div>        
    </form>
</body>
</html>

<script type="text/javascript">
	mini.parse();
	var path;
	var form = new mini.Form("form1");
	//标准方法接口定义
    function SetData(data) {
            //跨页面传递的数据对象，克隆后才可以安全使用
            data = mini.clone(data);
            form.setData(data.row);
            form.setChanged(false);
            path=data.action;
    }

    function GetData() {
        var o = form.getData();
        return o;
    }
	//保存数据
	function SaveData() {
	    var o = form.getData(true); 
	    form.validate();
	    if (form.isValid() == false) return;
	    $.ajax({
	        url: path,
			type: 'post',
			dataType: 'json',
	        data: o,
	        cache: false,
	        success: function (text) {
	            if(text.success){
	            	window.CloseOwnerWindow("succ");
	            }else{
	            	mini.alert("数据错误");
	            }
	        },
	        error: function (jqXHR, textStatus, errorThrown) {
	            alert(jqXHR.responseText);
	            window.CloseOwnerWindow();
	        }
	    });
	}
	
    function CloseWindow(action) {            
        if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
        else window.close();            
    }
    
    function onOk(e) {
        SaveData();
    }
    
    function onCancel(e) {
        CloseWindow("cancel");
    }
    
    //验证
    function onserialNumValidation(e) {
    	 var id =e.sender.name + "_error";
         var el = document.getElementById(id);
         checkValidation(e);
    }
    
    function updateError(e) {
        var id =e.sender.name + "_error";
        var el = document.getElementById(id);
        if (el) {
            el.innerHTML =e.errorText;
        }
    }
    
    function checkValidation(e) {
        updateError(e);
    }
</script>